package top.zhangjianyong.tools.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import top.zhangjianyong.tools.service.api.MairuiService;
import top.zhangjianyong.tools.user.VerifyUser;
import top.zhangjianyong.tools.utils.ApiResponse;

import java.io.IOException;
import java.time.LocalDate;
import java.util.List;

/**
 * @author ： zhangjianyong
 * @date ： 2022/10/13 8:58 AM
 */
@VerifyUser(login = false)
@RestController
@RequestMapping("/mairui")
public class MairuiController {

    @Autowired
    private MairuiService mairuiService;


    @PostMapping("/jj/all")
    public ApiResponse all() {
        return mairuiService.all();
    }

    @PostMapping("/jjgk/{dm}")
    public ApiResponse jjgk(@PathVariable("dm") String dm) {
        return mairuiService.jjgk(dm);
    }

    @PostMapping("/gp/jz/{dm}")
    public ApiResponse gpjz(@PathVariable("dm") String dm) {
        return mairuiService.gpjz(dm);
    }

    @PostMapping("/jj/gz/{dm}")
    public ApiResponse jjgz(@PathVariable("dm") String dm) {
        return mairuiService.jjgz(dm);
    }

    @PostMapping("/jj/gz/pl/{num}")
    public ApiResponse jjgzpl(@PathVariable("num") Integer num) {
        return mairuiService.jjgzpl(num);
    }

    @PostMapping("/jj/gz/pl")
    public ApiResponse jjgzpl(@RequestBody List<String> dms) {
        return mairuiService.jjgzpl(dms);
    }

    @PostMapping("/jj/hot")
    public ApiResponse jjHot(@RequestParam("file") MultipartFile file) throws IOException {
        return mairuiService.jjHot(file);
    }

    @PostMapping("/jj/hot/gz")
    public ApiResponse jjHotGz() {
        return mairuiService.jjHotGz();
    }

    @PostMapping("/jj/hot/cc")
    public ApiResponse jjHotCc() {

        return mairuiService.jjHotCC(LocalDate.now());
    }

    @PostMapping("/jj/hot/cc/{date}")
    public ApiResponse jjHotCc(@PathVariable("date") LocalDate date) {

        return mairuiService.jjHotCC(date);
    }

    @PostMapping("/jj/hot/up")
    public ApiResponse jjHotUp() {
        return mairuiService.jjHotUp();
    }


    @PostMapping("/jj/gpcc/{code}")
    public ApiResponse jjGpcc(@PathVariable("code") String code) {
        return mairuiService.jjGpcc(code);
    }
}
